package cn.hznc.constant;

import cn.hznc.vo.RecordGroupCraftToolIndexVo;
import cn.hznc.vo.RecordGroupMachineToolIndexVo;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author：Administrator
 * @Date：2023/12/4 10:57
 */
public enum SortRecordReloadEnum implements SortRecordReload{

    Number{
        @Override
        public List<RecordGroupCraftToolIndexVo> sortByConditionReload(List<RecordGroupCraftToolIndexVo> recordEntities, Integer sortType){
            if(sortType == 0){
                //正序
                return recordEntities
                        .stream()
                        .sorted(Comparator.comparing(RecordGroupCraftToolIndexVo::getNumber , Comparator.comparing(Integer::valueOf)))
                        .collect(Collectors.toList());
            }
            //倒序
            return recordEntities
                    .stream()
                    .sorted(Comparator.comparing(RecordGroupCraftToolIndexVo::getNumber , Comparator.comparing(Integer::valueOf)).reversed())
                    .collect(Collectors.toList());
        }
    },


    Price{
        @Override
        public List<RecordGroupCraftToolIndexVo> sortByConditionReload(List<RecordGroupCraftToolIndexVo> recordEntities, Integer sortType){
            if(sortType == 0){
                //正序
                return recordEntities
                        .stream()
                        .sorted(Comparator.comparing(RecordGroupCraftToolIndexVo::getPrice , Comparator.comparing(Double::valueOf)))
                        .collect(Collectors.toList());
            }
            //倒序
            return recordEntities
                    .stream()
                    .sorted(Comparator.comparing(RecordGroupCraftToolIndexVo::getPrice , Comparator.comparing(Double::valueOf)).reversed())
                    .collect(Collectors.toList());
        }
    };
}
